import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:libflutter/weather/TestWeacherAppWidget.dart';
import 'package:provider/provider.dart';

class HomeScreen extends StatefulWidget {

  static const routeName = "/";

  const HomeScreen({super.key});

  @override
  State<StatefulWidget> createState() {
    return _HomeScreenState();
  }
}

class _HomeScreenState extends State<HomeScreen> {

  final PageController _pageController = PageController();
  bool _isLoading = false;

  void _getData() async {
    _isLoading = true;
    final weatherData = Provider.of<WeatherProvider>(context, listen: false);
    weatherData.getWeatherData(context);
    _isLoading = false;
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    print(" build >>> ");
    final provider = Provider.of<WeatherProvider>(context, listen: true);
    return Scaffold(
      appBar: AppBar(title: const Text("Home"),),
      body: Column(
        children: [
          Text(" Count >> ${ provider.count}"),
          TextButton(onPressed: () {
            provider.addCount();
          }, child: Text("add")),
        ],
      ),
    );
  }
}
